/*
 * $Id: Curry.java,v 1.2 2007-07-24 10:30:08 klose Exp $
 */
package de.fanuffel.generic.functions;

import de.fanuffel.generic.structures.Pair;

/**
 * Curry : (Ax(B->C))xA -> B->C
 * 
 * @author Karl Klose
 */
public class Curry<A, B, C> implements
    Function<Function<Pair<A, B>, C>, Function<A, Function<B, C>>> {
  public Function<A, Function<B, C>> eval(final Function<Pair<A, B>, C> f) {
    return new Function<A, Function<B, C>>() {
      public Function<B, C> eval(final A a) {
        return new Function<B, C>() {
          public C eval(final B b) {
            return f.eval(new Pair<A, B>(a, b));
          }
        };
      }
    };
  }
}
